package com.symaster.backups.repository;

import com.symaster.backups.model.FileSystemMonitorModel;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

/**
 * @author yinmiao
 * @version 2024/2/5
 */
@Repository
public interface FileSystemMonitorRepository extends JpaRepository<FileSystemMonitorModel, Integer> {

    @Query(value = "select * from bk_file_system_monitor where delete_status = false and monitor = true", nativeQuery = true)
    List<FileSystemMonitorModel> monitorAll();

    @Query(value = "select * from bk_file_system_monitor where delete_status = false", nativeQuery = true)
    List<FileSystemMonitorModel> views();

    @Query(value = "select * from bk_file_system_monitor where path_name = ?1", nativeQuery = true)
    Optional<FileSystemMonitorModel> findOneByPathName(String pathName);
}
